<?php

class Obj_DBTable_References extends Zend_Db_Table_Abstract
{
    protected $_name = 'references';
    protected $_primary = 'ID';
    
    
    public function getAdminReferences() {
    	$select = $this->select()->from($this)->order('Approved')->order("Created desc");
    	$arResult = $this->fetchAll($select)->toArray();
    	return $arResult;
    }
    
    public function getReferences() {
    	$select = $this->select()->from($this)->order("Created desc")->where('Approved = 1');
    	$arResult = $this->fetchAll($select)->toArray();
    	return $arResult;
    }
    
    public function getReference($id) {
    	$select = $this->select()->from($this)->where('ID = ?', (int) $id);
    	$arResult = $this->fetchRow($select);
    	if ($arResult) return $arResult->toArray();
    	return false;
    }
    
    public function getLastReferences(){
    	$select = $this->select()->from($this)->order('Created desc')->where('Approved = 1')->limit(3);
    	return $this->fetchAll($select)->toArray();
    }

}